package com.proyecto.robomind.model;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class MapSquare {
	
	private String character;
	private int height;
	private int width;
	private int x;
	private int y;
	
	private String[] characters = {"e","b","h","f","r","t","s","o"};
	
	private int[] R = {255,195,147,129,129,49,48,148};
	private int[] G = {255,211,185,103,136,209,233,65};
	private int[] B = {255,223,46,64,132,73,236,65};
	
	public MapSquare(int height, int width, int x, int y){
		character = "";
		this.height = height;
		this.width = width;
		this.x = x;
		this.y = y;
	}
	
	public String getCharacter(){
		return character;
	}
	public void setCharacter(String character){
		this.character = character;
	}
	
	public int getX(){
		return x;
	}
	
	public int getY(){
		return y;
	}
	
	public int getWidth(){
		return width;
	}
	
	public int getHeight(){
		return height;
	}
	
	private int getColor(String character){
		int colorCount = 0;
		for(int i = 0; i < characters.length; i++){
			if(character.equals(characters[i])){
				colorCount = i;
			}
		}
		return colorCount;
	}
	
	public void draw(Canvas canvas){
		Rect rect = new Rect(x,y,x+width,y+height);
		Paint paint = new Paint();
		int colorCount = getColor(character);
		paint.setARGB(255, R[colorCount], G[colorCount], B[colorCount]);
		canvas.drawRect(rect, paint);
		
		paint.setARGB(255,0,0,0);
		canvas.drawText(character.toUpperCase(), x+(width/2),y+(height/2),paint);
	}	
}
